package com.wy2cloud.jjwt.security;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;


public final class SecurityUserFactory {

    private SecurityUserFactory() {
    }

    public static SecurityUser generator(String userId,String userName,String password,Collection<? extends GrantedAuthority> authorities,Date lastPasswordResetDate) {
        return new SecurityUser(
        		userId,
        		userName,
        		password,
        		authorities,
        		lastPasswordResetDate
        );
    }

    private static List<GrantedAuthority> mapToGrantedAuthorities(List<String> authorities) {
        return authorities.stream()
                .map(SimpleGrantedAuthority::new)
                .collect(Collectors.toList());
    }
}